<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>管理中心</title>
<script type="text/javascript" src="scripts/jquery.js"></script>
</head>
<body>
<!--{include file="top.htm"}-->
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="150" valign="top"><!--{include file="left.htm"}--></td>
<td valign="top">
<div class='title'>
<a href="?action=config&do=admin_list">管理员列表</a>
&raquo;&nbsp;<!--{if $mode=='insert'}-->添加管理员<!--{else}-->编辑管理员<!--{/if}-->

</div>
<div class='item'>
	<table width="100%">
	<form action="?action=config&do=admin_<!--{$mode}-->" method="post" name="admin_info">
		<tr>
		<td align="right" width="80" height="30">管理员名称：</td>
		<td><!--{if $mode=='insert'}--><input type="text" name="admin_name" size="40" value="<!--{$admin.name|escape:html}-->" class="input"/>
		<!--{else}-->
		<input type="hidden" name="admin_name" value="<!--{$admin.name|escape:html}-->" />
		<!--{$admin.name|escape:html}-->
		<!--{/if}--></td>
		</tr>

		<tr>
		<td align="right"  height="30">管理员密码：</td>
		<td><input type="password" name="admin_password" size="40" value="" class="input"/></td>
		</tr>
		<!--{if $smarty.session.admin_name!=$admin.name}-->
		<tr>
		<td align="right"  height="30">管理员权限：</td>
		<td>
			<label><input type="radio" name="admin_permissions" onclick="display_permissions(false)" value="all"{if $admin.permissions=='all'} checked{/if} /> 超级管理员</label>
			<label><input type="radio" name="admin_permissions" onclick="display_permissions(true)" id="admin_permissions_normal" value="<!--{$admin.permissions}-->" {if $admin.permissions!='all'}checked{/if} /> 副管理员</label>
		</td>
		</tr>

		<tr id="permissionss"  {if $admin.permissions=='all'}style="display:none"{/if}>
		<td align="right">&nbsp;</td>
		<td>
		<table bgcolor="#cccccc" cellpadding="1" cellspacing="1">
		<tr>
		<td width="80" bgcolor="#f4f4f4" align="center" height="25">&nbsp;</td>
		<td width="70" bgcolor="#ffffff" align="center" >读取权限</td>
		<td width="70" bgcolor="#ffffff" align="center" >写入权限</td>
		<td width="70" bgcolor="#ffffff" align="center" >删除权限</td>
		</tr>
	

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">菜单管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="menu_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="menu_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="menu_delete" onclick="push_permissions(this)"/></td>
		</tr>


		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">频道管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="channel_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="channel_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="channel_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">分类管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="category_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="category_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="category_delete" onclick="push_permissions(this)"/></td>
		</tr>


		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">内容管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="content_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="content_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="content_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">单页管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="page_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="page_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="page_delete" onclick="push_permissions(this)"/></td>
		</tr>



		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">评论管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="comment_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="comment_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="comment_delete" onclick="push_permissions(this)"/></td>
		</tr>		

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">会员管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="member_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="member_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="member_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">会员组管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="member_group_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="member_group_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="member_group_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">广告管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="ad_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="ad_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="ad_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">投票管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="vote_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="vote_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="vote_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">链接管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="link_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="link_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="link_delete" onclick="push_permissions(this)"/></td>
		</tr>

		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">横幅管理</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="banner_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="banner_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="banner_delete" onclick="push_permissions(this)"/></td>
		</tr>
		<tr>
		<td bgcolor="#f4f4f4" align="center" height="25">留言反馈</td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="feedback_read" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="feedback_write" onclick="push_permissions(this)"/></td>
		<td bgcolor="#ffffff" align="center"><input type="checkbox" value="feedback_delete" onclick="push_permissions(this)"/></td>
		</tr>	
	
		</table>
		</td>
		</tr>
		<tr>
		<td align="right" height="30">管理员状态：</td>
		<td>
		
		<label><input type="radio" name="admin_state" value="1" {if $admin.state==1}checked{/if} /> 正常</label>
		<label><input type="radio" name="admin_state" value="0" {if $admin.state==0}checked{/if} /> 锁定</label>
		</td>
		</tr>
		<!--{else}-->
		<input type="hidden" name="admin_permissions" value="<!--{$admin.permissions}-->" />
		<input type="hidden" name="admin_state" value="<!--{$admin.state}-->" />
		<!--{/if}-->
		<tr>
		<td align="right" height="30">&nbsp;</td>
		<td>
		<input type="submit" value="提交" class="button"/>
		</td>
		</tr>
		<input type="hidden" name="admin_id" value="<!--{$admin.id}-->"/>
	</form>
	</table>
</div>
</td>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
check_permissions('<!--{$admin.permissions}-->');

function display_permissions(mode){
	if (mode){
		$('#permissionss').show();
	}else{
		$('#permissionss').hide();
	}
}

function push_permissions(obj){
	if (obj.checked){
		var $array=[];
		if ($("#admin_permissions_normal").val()!=""){
			var $admin_permissions_value=$("#admin_permissions_normal").val();
			var $admin_permissions_value_split=$admin_permissions_value.replace(/ /g,"").split(",");	
			if ($admin_permissions_value_split.length>0){
				for (var $i=0;$i<$admin_permissions_value_split.length;$i++){
					$array.push($admin_permissions_value_split[$i]);
				}
			}
		}
		$array.push(obj.value);
		$("#admin_permissions_normal").val($array.join(","));
	}else{
		var $array=[];
		if ($("#admin_permissions_normal").val()!=""){
			var $admin_permissions_value=$("#admin_permissions_normal").val();
			var $admin_permissions_value_split=$admin_permissions_value.replace(/ /g,"").split(",");	
			if ($admin_permissions_value_split.length>0){
				for (var $i=0;$i<$admin_permissions_value_split.length;$i++){
					if (obj.value!=$admin_permissions_value_split[$i]){
						$array.push($admin_permissions_value_split[$i]);
					}
				}
			}
		}
		$("#admin_permissions_normal").val($array.join(","));
	}
}
function check_permissions(permissions){
	var l=permissions.split(",");
	var f=document.forms['admin_info'];
		for (var i=0;i<f.elements.length ;i++ ){
			if (f.elements[i].type=='checkbox'){
				for (var j=0;j<l.length ;j++ ){
					if (f.elements[i].value==l[j]){
						f.elements[i].checked=true;
					}
				}
			}
		}
}
</script>